import { getlist , delet , updates , inster} from "@/api/classify"

const state = {
    table:[]
}

const mutations = {
    SET_CIDS(state,classifyList){
        state.classifyList = classifyList
    }
}

const actions = {
    async getCid({commit}) {
       let { data } = await getlist()
       let r = [{}].concat(data)
       commit('SET_CIDS',r)
    },
    async addList({dispatch},data){
        await inster(data)
        dispatch('getCid')
    },
    async delList({dispatch},id) {
        await delet(id)
        dispatch('getCid')
    },
    async updateList({dispatch , state},data) {
        await updates(data)
        dispatch('getCid')
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}